package com.greenline.search.report.util;

import com.greenline.search.report.entity.LogReportResult;
import com.greenline.search.report.entity.SearchWord;
import com.greenline.search.report.model.Configuration;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: liulei
 * Date: 14-2-17
 * Time: 上午11:33
 * To change this template use File | Settings | File Templates.
 */
public class FormatNoResultWordUtil {
    private static String newLine = "\n";
    private static String tagString = "\t";

    //格式化无结果词成html格式，以供在邮件中显示
    public static String getAllFormatedResult(List<SearchWord> doctorWordList, List<SearchWord> hospitalWordList){
        StringBuilder sb = new StringBuilder();
        sb.append("<table border=1 cellspacing=0 style=border-collapse:collapse>");
        sb.append("<tr><td colspan=9><center><h2>搜索无结果词周报</h2></center></td></tr>");
        sb.append(newLine);
        sb.append("<tr><td colspan=9></td></tr>");
        sb.append("<tr>");
        sb.append("<td colspan=4><center><h3>");
        sb.append("医生搜索").append("</center></h3></td>");
        sb.append("<td></td>");
        sb.append("<td colspan=4><center><h3>");
        sb.append("医院搜索").append("</h3></center></td>");
        sb.append("</tr>");
        sb.append(newLine);
        sb.append("<tr>");
        sb.append("<td>排名</td>");
        sb.append("<td>关键词</td>");
        sb.append("<td>搜索量</td>");
        sb.append("<td>搜索词排名</td>");
        sb.append("<td></td>");
        sb.append("<td>排名</td>");
        sb.append("<td>关键词</td>");
        sb.append("<td>搜索量</td>");
        sb.append("<td>搜索词排名</td>");
        sb.append("</tr>");
        sb.append(newLine);

        for(int i = 0; i < doctorWordList.size(); i++){
            SearchWord doctorWord = doctorWordList.get(i);
            SearchWord hospitalWord = hospitalWordList.get(i);
            sb.append("<tr>");
            sb.append("<td>").append(i+1).append("</td>");
            sb.append("<td>").append(doctorWord.getText()).append("</td>");
            sb.append("<td>").append(doctorWord.getFrequency()).append("</td>");
            sb.append("<td>").append(doctorWord.getCurrentWeekRank()).append("</td>");
            sb.append("<td>").append("").append("</td>");
            sb.append("<td>").append(i+1).append("</td>");
            sb.append("<td>").append(hospitalWord.getText()).append("</td>");
            sb.append("<td>").append(hospitalWord.getFrequency()).append("</td>");
            sb.append("<td>").append(hospitalWord.getCurrentWeekRank()).append("</td>");
            sb.append("</tr>");
            sb.append(newLine);
        }

        sb.append("<tr><td colspan=9></td></tr>").append(newLine);
        sb.append(newLine);
        sb.append("</table>");
        return sb.toString();
    }

}
